package pagerouter

import (
	"net/http"
	"text/template"

	"gitee.com/chenrh/ios-local/AppDdistribute/libs"
)

func List(w http.ResponseWriter, req *http.Request) {

	viewdata := map[string]interface{}{}

	appnames := libs.AppNames()
	viewdata["appnames"] = appnames

	t, _ := template.ParseFiles("./views/app-list.html")
	t.Execute(w, viewdata)
}

func AppVersionList(w http.ResponseWriter, req *http.Request) {

	vars := req.URL.Query()
	ids := vars["id"]

	if len(ids) == 0 {
		w.Write([]byte("参数id值为空"))
		return
	}
	bundleid := ids[0]

	appnames := libs.AppVersion(bundleid)
	viewdata := map[string]interface{}{}
	viewdata["appnames"] = appnames
	viewdata["appid"] = bundleid

	t, _ := template.ParseFiles("./views/app-list-version.html")
	t.Execute(w, viewdata)
}
